package org.xs.web.http.velocity;

import java.util.Map;

import org.apache.velocity.VelocityContext;
import org.apache.velocity.context.Context;
import org.xs.web.http.S;

public class ChainedContext extends VelocityContext implements ViewContext{
 	protected Map<Object, Object> velocityCore;
	
	public ChainedContext(Map<Object, Object> velocityCore){
		super(velocityCore);
		this.velocityCore = velocityCore;
	}
	
	@Override
	public Object internalGet( String key ){
		Object result = super.internalGet(key);
		if(result == null){
			result = S.xsContext().get(key);
		}
		if(result == null){
			result= S.getContext().get(key);
		}
		return result;
		 
	}
	
	
	
	@Override
	public Object getAttribute(String key) {
		return null;
	}

	@Override
	public Context getVelocityContext() {
		return this;
	}

	 

}
